<?php

namespace api\controller;

// +----------------------------------------------------------------------
// | 基础模块（任务文件）数据控制层
// +----------------------------------------------------------------------

use common\controller\VerifyController;
use common\exception\LogicException;
use common\service\TaskFileService;
use support\ErrorCode;
use think\Exception;
use think\Request;
use think\Response;
use Throwable;

class TaskFileController extends VerifyController
{
    private $taskFileService;
    public function __construct()
    {
        parent::__construct();
        $this->taskFileService = new TaskFileService();
    }

    /**
     * 获取任务最新版本信息
     * @param \think\Request $request
     *
     * @return \think\Response
     */
    public function getLatestPublishedVersionByTaskId(Request $request)
    {
        $param = $request->param()['param'];
        $result =  $this->taskFileService->getLatestPublishedVersionByTaskId($param);
        return json(success_response('ok',$result));
    }


	/**
	 * 获取任务参考文件
	 * @param \think\Request $request
	 *
	 * @return \think\Response
	 */
	public function getReferenceFiles(Request $request)
	{
		$param = $request->param()['param'];
		$result =  $this->taskFileService->getReferenceFiles($param);

		return json(success_response('ok',$result));
	}


	/**
	 * 获取任务上游文件
	 * @param \think\Request $request
	 *
	 * @return \think\Response
	 */
	public function getUpstreamFileByTask(Request $request)
	{
		$param = $request->param()['param'];
		$result =  $this->taskFileService->getUpstreamFileByTask($param);

		return json(success_response('ok',$result));
	}

}
